/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2022-03-21
 * Time:23:19
 */
import java.util.Scanner;
public class Test {
    //递归形式——返回的数字之和
    public static int fun(int a){
        if(a<10){
            return a;
        }
        return a%10+fun(a/10);
    }
    //添加判断多少位数
    public static int wei(int a){
        int count=0;
        while(a>0){
            a/=10;
            count++;
        }
        return count;
    }
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        System.out.print("请输入一个数字：");
        int num=in.nextInt();
        int sum=fun(num);
        int count=wei(num);
        System.out.println(sum);
        //System.out.println(count);
    }
}
